On Docker
__TOC__ Overview * http://www.docker.com/ * Desc. : automates the deployment of Linux applications inside software containers. * License : * Written : Go * Sources : ** https://github.com/docker/docker ** https://github.com/docker/toolbox References * Docker Overview * Docker current version documentations Docker 18 * Docker v18.03 documentations * Dockerfile reference Command-lines * Docker Engine CLI (docker, dockerd) Docker 1.11 * Docker 1.11 documentations * Dockerfile reference * docker run reference ** IPC settings (--ipc) * Use the Docker command line ** docker logs references ** docker rm references ** docker inspect references *** Go Templates * Docker Machine * [https://docs.docker.com/v1.11/machine/get-started/ Get started with Docker Machine and a local VM] * Docker Machine command line reference Readings * Docker Training * New Stack's eBooks ** The Docker and Container Ecosystem ** Networking, Security and Storage with Docker & Containers Boot2Docker * Boot2Docker on GitHub Events * Docker Events * Docker Events Explained (APR 14 2015) Storage * What is the (best) way to manage permissions for docker shared volumes (May 8 '14) * boot2docker folder sharing * What's the best way to share files from Windows to Boot2docker VM (Jun 16 '15) mkdir c:\var "%VBOX_MSI_INSTALL_PATH%\VBoxManage" sharedfolder add default --name c/var --hostpath c:\var --automount docker-machine ssh default sudo mkdir /c/var docker-machine ssh defalut sudo mount -t vboxsf -o uid=1000,gid=50 c/var /c/var docker run -v /c/var/opt:/var/opt:rw ... * Manage data in Docker * Storage Driver ** [https://docs.docker.com/engine/userguide/storagedriver/ Docker storage drivers] ** Select a storage driver ** Use the Device Mapper storage driver * Slow IO performance inside container compared with the host. (25 Mar 2016) Networking * [https://docs.docker.com/engine/tutorials/networkingcontainers/ Network containers] * Connect containers * Is it possible to bind a container to multi networks? (6 Nov 2015) * Network param for connecting to 127.0.0.1 in container (Jul '15) * Customize the docker0 bridge ** Finally, the docker0 Ethernet bridge settings are used every time you create a new container. Docker selects a free IP address from the range available on the bridge each time you docker run a new container, and configures the container’s eth0 interface with that IP address and the bridge’s netmask. The Docker host’s own IP address on the bridge is used as the default gateway by which each container reaches the rest of the Internet. * Networking your docker containers using docker0 bridge (May 23, 2016) * Bridge the docker containers to external network(May 23, 2016) * The docker-proxy (April 15th, 2015) * Make it possible to disable userland proxy (Oct 2 2014) * MANAGING PERSISTENCE FOR DOCKER CONTAINERS (23 Sep 2016) * Storage Drivers in Docker: A Deep Dive (OCTOBER 1, 2016) misc * Docker Cheat Sheet * Install Docker on Ubuntu * [https://docs.docker.com/toolbox/toolbox_install_windows/ Install Docker for Windows] * [http://stackoverflow.com/questions/33392133/move-boot2docker-and-docker-folder-in-other-drive Move boot2docker and .docker folder in other drive] (Oct 28 '15) * Eclipse for Docker has arrived on Mars * Stop / remove all Docker containers * Running GUI apps with Docker(2014/09/11) * Can you run GUI apps in a docker container?(Apr 30 '13) * [https://github.com/SeleniumHQ/docker-selenium/issues/76 Setting up VNC fails] (9 Jul 2015) ** docker-machine ip * Where are Docker images stored? (12 december 2013) * Where are docker images stored on the host machine?(Oct 7 '13) * [http://developerblog.redhat.com/2014/05/05/running-systemd-within-docker-container/ Running systemd within a Docker Container] (May 5, 2014) * [https://github.com/docker/docker/issues/7459 Failed to get D-Bus connection: No connection to service manager - CentOS 7] (7 Aug 2014) * HANDLING PERMISSIONS WITH DOCKER VOLUMES (2016-02-17) * Docker, QML, XServer on Windows (17 Nov 2015) * [https://linuxmeerkat.wordpress.com/2014/10/17/running-a-gui-application-in-a-docker-container/ Running a GUI application in a Docker container](October 17, 2014) * What are Docker : images? (16 July 2015) ** docker rmi $(docker images -f "dangling=true" -q) * Comparing Seven Monitoring Options for Docker (Apr 12, 2015) * Docker exec - Write text to file in container (Feb 29 '16) ** docker exec -it ... bash -c "echo 'On a dark desert highway, ...' > ~/lyrics/hotel-california.txt" * iptables sometimes works inside container, sometimes not - docker 0.8.1 (4 Mar 2014) ** running with -privileged option works ok everytime. * Dynamic Zookeeper Cluster with Docker * Slow IO performance inside container compared with the host. (25 Mar 2016) * Best practices for writing Dockerfiles * Absolute paths change with git bash on windows (28 Jun 2016) ** MSYS_NO_PATHCONV=1 * Using Docker containers as localhost on Mac/Windows ** A Docker Machine is a virtual machine running under VirtualBox in your host machine. We can use the Port Forwarding feature of VirtualBox in order to access the Docker VM as localhost. Repositories * Docker Hub * Docker Hub JBoss Repository Images * Dockerfiles ** Dockerfile for WildFly 10.1.0.Final * Library ** Docker official images ** Docker official image packaging for WordPress * WildFly ** Docker and WildFly Part 1 - Deployment via Docker volumes (Mar 02, 2015) ** WildFly Admin Console in a Docker image (January 5, 2015) Docker Compose * https://docs.docker.com/compose/ * Desc. : a tool for defining and running multi-container Docker applications. * Readings ** Compose file version 3 reference *** Variable substitution ** Compose file version 2 reference ** Compose file version 1 reference ** Docker Compose CLI Swarm Mode * Getting started with swarm mode Docker Machine * https://github.com/docker/machine * Desc. : lets you create Docker hosts on your computer, on cloud providers, and inside your own data center. * Readings ** Understand Machine concepts and get help Docker Toolbox * https://github.com/docker/toolbox * Desc. : installs everything you need to get started with Docker on Mac OS X and Windows. Readings * Fixing Volumes in Docker Toolbox (Sep 6, 2018) * How to use --volume option with Docker Toolbox on Windows? (Oct 14 '15) Companions Kubernetes * http://kubernetes.io/ * Desc. : an open-source system for automating deployment, scaling, and management of containerized applications. * License : * Sources : * Readings ** Kubernetes cluster monitoring (via Prometheus) cAdvisor * https://github.com/google/cadvisor * Desc. : Analyzes resource usage and performance characteristics of running containers. * License : * Sources : https://github.com/google/cadvisor * Readings ** How to setup Docker Monitoring (May 20, 2015) ** Exporting cAdvisor Stats to InfluxDB Tips and Tricks Identifying versions of Docker Engine, Docker Compose and Docker Machine To indentify Docker Engine version $ docker version --format ' ' To identify Docker Compose version $ docker-compose version To identify Docker Machine version $ docker-machine version For more, refer the followings * docker version Removing all containers in a single command-line If there's no running container, just use $ docker rm $(docker ps -a -q) If there's running containers also, use one of the followings $ docker rm -f $(docker ps -a -q) or $ docker stop $(docker ps -q) $ docker rm $(docker ps -a -q) Shell login to running docker container In the following command line hyperledger_vp0_1 is the name of container to access. $ docker exec -it hyperledger_vp0_1 /bin/bash Inspect low-level information of container including configuration * go inspect command $ docker inspect hyperledger_vp0_1 Inject configuration file into container deferring the built-in command In the following example, hyperledger/fabric-couchdb's built-in command (/opt/couchdb/bin/couchdb) is deferred by being overriden at docker run command. The configuration file is injected using docker exec command with here-documents and then built-in command (/opt/couchdb/bin/couchdb) starting CouchDB is executed in another docker exec command. #! /bin/bash # For more on CouchDB configuration, refer # -http://docs.couchdb.org/en/2.0.0/config/ # -http://docs.couchdb.org/en/2.0.0/config-ref.html : CouchDB configuration reference name=couchdb0 port=${COUCHDB_PORT:-5984} sudo rm -rf ~/docker/opt/couchdb/$name docker run -itd \ --name $name \ -p $port:5984 \ -v ~/docker/opt/couchdb/$name/data:/opt/couchdb/data \ -v ~/docker/opt/couchdb/$name/var/log:/opt/couchdb/var/log \ hyperledger/fabric-couchdb /bin/bash echo "Waiting 2 seconds for CouchDB to be launched completely." sleep 2 docker exec -it $name bash -c "cat >> /opt/couchdb/etc/local.d/docker.ini << HERE log file = /opt/couchdb/var/log/couch.log writer = file level = ${COUCHDB_LOG_LEVEL:-info} HERE" echo "Waiting 2 seconds for 'docker exec' to be completed." sleep 2 docker exec -itd $name "/opt/couchdb/bin/couchdb" if [ $? -eq 0 ]; then echo "" echo "CouchDB container named '$name' has launched successfully." echo "Access 'http://localhost:$port/_utils' to manage $name." echo "Data files : '~/docker/opt/couchdb/$name/data' in host filesystem." echo "Log files : '~/docker/opt/couchdb/$name/var/log' in host filesystem." echo "" fi